<?php

class AreaRoomFormatClass
{
	var $AreaUnits;
	var $DimensionsUnits;
	var $Length;
	var $Width;
		
	var $ID;
	
	function AddItemFromXML($XmlArray)
	{
		$Array = $XmlArray->children();
			
		$this->AreaUnits = $Array[0]->attributes("Units");
		$this->DimensionsUnits = $Array[1]->attributes("Units");
	
		$this->Length = $Array[2];
		$this->Width = $Array[3];
	}

	function InsertSQL()
	{
		$strSqlCommand = "INSERT INTO AreaRoomFormat( AreaUnits, DimensionsUnits, ";
		$strSqlCommand .="Length, Width) ";
		$strSqlCommand .= "VALUES( '".$this->AreaUnits."', ";
		$strSqlCommand .= "'".$this->DimensionsUnits."', ";
		$strSqlCommand .= "'".$this->Length."', ";
		$strSqlCommand .= "'".$this->Width."') ";
				
		if(!mysql_query($strSqlCommand))
		{
			echo $strSqlCommand."<br/>";
		}
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
		$this->ID = $InputID;

		$strSqlCommand =  "UPDATE AreaRoomFormat SET ";
		$strSqlCommand .= "AreaUnits='"		.$this->AreaUnits		."', ";
		$strSqlCommand .= "DimensionsUnits='".$this->DimensionsUnits	."', ";
		$strSqlCommand .= "Length='"		.$this->Length			."', ";
		$strSqlCommand .= "Width='"			.$this->Width			."' ";
		$strSqlCommand .= "WHERE idLotSize = ".$this->ID;
		mysql_query($strSqlCommand);		
	}			
	
}

class LivingAreaClass
{
	var $AreaUnits;
		
	var $ID;
	
	function AddItemFromXML($XmlArray)
	{
		$Array = $XmlArray->children();
			
		$this->AreaUnits = $Array[0]->attributes("Units");
	}

	function InsertSQL()
	{
		$strSqlCommand = "INSERT INTO AreaRoomFormat( AreaUnits) ";
		$strSqlCommand .= "VALUES( '".$this->AreaUnits."') ";
				
		if(!mysql_query($strSqlCommand))
		{
			echo $strSqlCommand."<br/>";
		}
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
		$this->ID = $InputID;

		$strSqlCommand =  "UPDATE AreaRoomFormat SET ";
		$strSqlCommand .= "AreaUnits='"		.$this->AreaUnits		."' ";
		$strSqlCommand .= "WHERE idLotSize = ".$this->ID;
		mysql_query($strSqlCommand);		
	}			
	
}

class ParkingClass
{
	var $Garage;
	var $CarPort;
		
	var $ID;
	
	function AddItemFromXML($XmlArray)
	{
		$Array = $XmlArray->children();
	
		$this->Garage = $Array[0];
		$this->CarPort = $Array[1];
	}

	function InsertSQL()
	{
		$strSqlCommand = "INSERT INTO Parking( Garage, CarPort) ";
		$strSqlCommand .= "VALUES( '".$this->Garage."', ";
		$strSqlCommand .= "'".$this->CarPort."') ";
				
		if(!mysql_query($strSqlCommand))
		{
			echo $strSqlCommand."<br/>";
		}
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
		$this->ID = $InputID;

		$strSqlCommand =  "UPDATE Parking SET ";
		$strSqlCommand .= "Garage='"		.$this->Garage		."', ";
		$strSqlCommand .= "CarPort='"		.$this->CarPort	."', ";
		$strSqlCommand .= "WHERE idParking = ".$this->ID;
		mysql_query($strSqlCommand);		
	}			
	
}

class BathsClass
{
	var $BathTotal;
	var $BathsFull;
	var $BathsHalf;
	var $BathsThreeQuarter;
		
	var $ID;
	
	function AddItemFromXML($XmlArray)
	{
		$Array = $XmlArray->children();
			
		$this->BathTotal = $Array[0];
		$this->BathsFull = $Array[1];
		$this->BathsHalf = $Array[2];
		$this->BathsThreeQuarter = $Array[3];
	}

	function InsertSQL()
	{
		$strSqlCommand = "INSERT INTO Baths( BathTotal, BathsFull, ";
		$strSqlCommand .="BathsHalf, BathsThreeQuarter) ";
		$strSqlCommand .= "VALUES( '".$this->BathTotal."', ";
		$strSqlCommand .= "'".$this->BathsFull."', ";
		$strSqlCommand .= "'".$this->BathsHalf."', ";
		$strSqlCommand .= "'".$this->BathsThreeQuarter."') ";
				
		if(!mysql_query($strSqlCommand))
		{
			echo $strSqlCommand."<br/>";
		}
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
		$this->ID = $InputID;

		$strSqlCommand =  "UPDATE Baths SET ";
		$strSqlCommand .= "BathTotal='"			.$this->BathTotal			."', ";
		$strSqlCommand .= "BathsFull='"			.$this->BathsFull			."', ";
		$strSqlCommand .= "BathsHalf='"			.$this->BathsHalf			."', ";
		$strSqlCommand .= "BathsThreeQuarter='"	.$this->BathsThreeQuarter	."' ";
		$strSqlCommand .= "WHERE idBaths = ".$this->ID;
		mysql_query($strSqlCommand);		
	}			
	
}

class UnitBathsClass
{
	var $BathsFull;
	var $BathsHalf;
		
	var $ID;
	
	function AddItemFromXML($XmlArray)
	{
		$Array = $XmlArray->children();
			
		$this->BathsFull = $Array[0];
		$this->BathsHalf = $Array[1];
	}

	function InsertSQL()
	{
		$strSqlCommand = "INSERT INTO Baths( BathsFull, BathsHalf) ";
		$strSqlCommand .= "VALUES( '".$this->BathsFull."', ";
		$strSqlCommand .= "'".$this->BathsHalf."') ";
				
		if(!mysql_query($strSqlCommand))
		{
			echo $strSqlCommand."<br/>";
		}
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
		$this->ID = $InputID;

		$strSqlCommand =  "UPDATE Baths SET ";
		$strSqlCommand .= "BathsFull='"			.$this->BathsFull			."', ";
		$strSqlCommand .= "BathsHalf='"			.$this->BathsHalf			."', ";
		$strSqlCommand .= "WHERE idBaths = ".$this->ID;
		mysql_query($strSqlCommand);		
	}			
	
}

class StreetAddressClass
{
	var $StreetNumber;
	var $StreetDirPrefix;
	var $StreetName;
	var $UnitNumber;
	var $City;
	var $StateOrProvince;
	var $PostalCode;
	
	var $ID;
	
	function AddItemFromXML($XmlArray)
	{
		$Array = $XmlArray->children();
			
		$this->StreetNumber = $Array[0];
		$this->StreetDirPrefix = $Array[1];
		$this->StreetName = $Array[2];
		$this->UnitNumber = $Array[3];
		$this->City = $Array[4];
		$this->StateOrProvince = $Array[5];
		$this->PostalCode = $Array[6];
	}
	
	function InsertSQL()
	{
		$strSqlCommand = "INSERT INTO StreetAddress( StreetNumber, StreetDirPrefix, ";
		$strSqlCommand .="StreetName, UnitNumber, City, StateOrProvince, PostalCode) ";
		$strSqlCommand .= "VALUES( '".$this->StreetNumber."', ";
		$strSqlCommand .= "'".$this->StreetDirPrefix."', ";
		$strSqlCommand .= "'".$this->StreetName."', ";
		$strSqlCommand .= "'".$this->UnitNumber."', ";
		$strSqlCommand .= "'".$this->City."', ";
		$strSqlCommand .= "'".$this->StateOrProvince."', ";
		$strSqlCommand .= "'".$this->PostalCode."') ";
				
		mysql_query($strSqlCommand);
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
		$this->ID = $InputID;

		$strSqlCommand =  "UPDATE StreetAddress SET ";
		$strSqlCommand .= "StreetNumber='"		.$this->StreetNumber	."', ";
		$strSqlCommand .= "StreetDirPrefix='"	.$this->StreetDirPrefix	."', ";
		$strSqlCommand .= "StreetName='"		.$this->StreetName		."', ";
		$strSqlCommand .= "UnitNumber='"		.$this->UnitNumber		."', ";
		$strSqlCommand .= "City='"				.$this->City			."', ";
		$strSqlCommand .= "StateOrProvince='"	.$this->StateOrProvince	."', ";
		$strSqlCommand .= "PostalCode='"		.$this->PostalCode		."' ";
		$strSqlCommand .= "WHERE idStreetAddress = ".$this->ID;
		mysql_query($strSqlCommand);		
	}		
}

class CurrencyFormatClass
{
	var $AttrCurrencyCode;
	var $AttrType;
	var $AttrValue;
	var $AttrPeriod;
	var $Currency;
	
	var $ID;

	function AddItemFromXML($XmlArray)
	{
		$this->CurrencyCode = $XmlArray->attributes("AttrCurrencyCode");
		$this->Type = $XmlArray->attributes("AttrType");
		$this->Value = $XmlArray->attributes("AttrValue");
		$this->Period = $XmlArray->attributes("AttrPeriod");
	 	$this->Currency = $XmlArray;
	}

	function InsertSQL()
	{
		$strSqlCommand = "INSERT INTO CurrencyFormat( AttrCurrencyCode, AttrType, ";
		$strSqlCommand .="AttrValue, AttrPeriod, Currency) ";
		$strSqlCommand .= "VALUES( '".$this->AttrCurrencyCode."', ";
		$strSqlCommand .= "'".$this->AttrType."', ";
		$strSqlCommand .= "'".$this->AttrValue."', ";
		$strSqlCommand .= "'".$this->AttrPeriod."', ";
		$strSqlCommand .= "'".$this->Currency."') ";
				
		mysql_query($strSqlCommand);
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
		$this->ID = $InputID;

		$strSqlCommand =  "UPDATE CurrencyFormat SET ";
		$strSqlCommand .= "AttrCurrencyCode='"	.$this->AttrCurrencyCode."', ";
		$strSqlCommand .= "AttrType='"			.$this->AttrType		."', ";
		$strSqlCommand .= "AttrValue='"			.$this->AttrValue		."', ";
		$strSqlCommand .= "AttrPeriod='"		.$this->AttrPeriod		."', ";
		$strSqlCommand .= "Currency='"			.$this->Currency		."' ";
		$strSqlCommand .= "WHERE idCurrencyFormat = ".$this->ID;
		mysql_query($strSqlCommand);		
	}		
}

class GeographicDataClass
{
	var $County;
	var $Directions;
	
	var $ID;

	function AddItemFromXML($XmlArray)
	{
		$Array = $XmlArray->children();
			
		$this->County = $Array[0];
		$this->Directions = $Array[1];
	}

	function InsertSQL()
	{
		$strSqlCommand = "INSERT INTO GeographicData( County, Directions) ";
		$strSqlCommand .= "VALUES( '".$this->County."', ";
		$strSqlCommand .= "'".$this->Directions."') ";
				
		mysql_query($strSqlCommand);
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
		$this->ID = $InputID;

		$strSqlCommand =  "UPDATE GeographicData SET ";
		$strSqlCommand .= "County='"	.$this->County		."', ";
		$strSqlCommand .= "Directions='".$this->Directions	."' ";
		$strSqlCommand .= "WHERE idGeographicData = ".$this->ID;
		mysql_query($strSqlCommand);		
	}		
}

class SchoolDataClass
{
	var $ElementarySchool;
	var $MiddleSchool;
	var $HighSchool;
	
	var $ID;

	function AddItemFromXML($XmlArray)
	{
		$Array = $XmlArray->children();
			
		$this->ElementarySchool = $Array[0];
		$this->MiddleSchool = $Array[1];
		$this->HighSchool = $Array[2];
	}

	function InsertSQL()
	{
		$strSqlCommand = "INSERT INTO SchoolData( ElementarySchool, MiddleSchool, ";
		$strSqlCommand .="HighSchool) ";
		$strSqlCommand .= "VALUES( '".$this->ElementarySchool."', ";
		$strSqlCommand .= "'".$this->MiddleSchool."', ";
		$strSqlCommand .= "'".$this->HighSchool."') ";
				
		mysql_query($strSqlCommand);
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
		$this->ID = $InputID;

		$strSqlCommand =  "UPDATE SchoolData SET ";
		$strSqlCommand .= "ElementarySchool='"	.$this->ElementarySchool."', ";
		$strSqlCommand .= "MiddleSchool='"		.$this->MiddleSchool	."', ";
		$strSqlCommand .= "HighSchool='"		.$this->HighSchool		."' ";
		$strSqlCommand .= "WHERE idSchoolData = ".$this->ID;
		mysql_query($strSqlCommand);		
	}		
}

class PictureDataClass
{
	var $PictureID;
	var $Internal;
	var $URL;
	
	var $ID;
	
	function AddItemFromXML($XmlArray)
	{
		$Array = $XmlArray->children();

		$this->PictureID = $Array[0];
		$this->Internal = $Array[1]->attributes("Internal");
	 	$this->URL = $Array[1];
	}

	function InsertSQL()
	{
		$strSqlCommand = "INSERT INTO PictureData( PictureID, isInternal, URL) ";
		$strSqlCommand .= "VALUES( '".$this->PictureID."', ";
		$strSqlCommand .= "'".$this->Internal."', ";
		$strSqlCommand .= "'".$this->URL."') ";
				
		mysql_query($strSqlCommand);
		$this->ID = mysql_insert_id();		
	}
	
	function ModifySQL( $InputID )
	{
		$this->ID = $InputID;

		$strSqlCommand =  "UPDATE PictureData SET ";
		$strSqlCommand .= "PictureID='"	.$this->PictureID	."', ";
		$strSqlCommand .= "isInternal='"	.$this->Internal	."', ";
		$strSqlCommand .= "URL='"		.$this->URL			."' ";
		$strSqlCommand .= "WHERE idPictureData = ".$this->ID;
		mysql_query($strSqlCommand);		
	}		
}

?>